import { defineStore } from "pinia";
import { computed, ref } from "vue";
import request from "../utils/request";
import { CategoryType } from "../types/job";
// 组合式写法

export const useCategory = defineStore(
  "category",
  () => {
    const list = ref<Array<CategoryType>>([]);
    const parentList = computed(() => {
      return list.value.filter((item) => item.parent == "0-0");
    });
    const initCategoryAction = async () => {
      let res = await request.get("classes/VueClassify");
      // console.log(res);
      list.value = res.data.results;
    };
    return {
      list,
      initCategoryAction,
      parentList,
    };
  },
  { persist: { key: "category-2304", storage: sessionStorage } } //开启当前模块持久化存储
);
